# 测试数据库连接
from src.config.database_peewee import pg

try:
    pg.connect()
    print("✅ 数据库连接成功")

    # 可选：执行一个简单查询，验证连接有效性
    result = pg.execute_sql("SELECT version();")
    version = result.fetchone()[0]
    print("Database version:", version)

except Exception as e:
    print("❌ 数据库连接失败:", str(e))

finally:
    if pg.is_closed() == False:
        pg.close()
        print("🔌 数据库连接已关闭")
